<?php
/*
 * IKPHP 爱客开源社区 @copyright (c) 2012-3000 IKPHP All Rights Reserved 
 * @author 小麦
 * @Email:ikphp@sina.cn 2014年8月7日23:19:19
 * 个人空间APP首页
 */
namespace IKPHP\Apps\Space\Controllers;

use IKPHP\Apps\Space\Controllers;
use IKPHP\Common\Models\User;
use IKPHP\Api\UserApi;
use IKPHP\Apps\Space\Models\UserFollow;

class IndexController extends SpaceBaseController
{
    public function initialize()
    {
        parent::initialize();
        // 访问者控制
		if ($this->visitor){
			$this->userid = $this->visitor['userid'];
		}else{
			$this->userid = 0;
		}
		
    }
    
    public function indexAction($id = '')
    {   
    	if(empty($id)) return $this->error ( '呃...你想要的东西不在这儿' );
    	
    	//根据ID获取uid; 判断是否是uid 还是doname
		$userid = $this->isValidUser($id);    	
		$strUser = User::getOneUser ( $userid ); 
		if(empty($strUser)) return $this->error ( '呃...你想要的东西不在这儿' );
		
		$strUser['isfollow'] = UserFollow::isFollow($this->userid, $userid);
		//关注的用户
		$strUser['followUser'] = UserFollow::getfollow_user($userid, 8);
		
		
		
    	$this->assign ( 'strUser', $strUser );
    	$this->assign ( 'isMe', $userid == $this->userid ? true : false );
	
    	$this->_config_seo ( array (
			'title' => $strUser['username'],
			'subtitle'=> '个人主页',
			'keywords' => clearText($strUser['signed']),
			'description'=> clearText($strUser['about']),
    		'userTitle' => $strUser['username']
		) );
    }

    

}